package cc.co.dreamind;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class MoneyTallyActivity extends Activity {
	
	TextView tx_amount;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        //FindView:
        Button bt_num0 = (Button)findViewById(R.id.number0);
        Button bt_num1 = (Button)findViewById(R.id.number1);
        Button bt_num2 = (Button)findViewById(R.id.number2);
        Button bt_num3 = (Button)findViewById(R.id.number3);
        Button bt_num4 = (Button)findViewById(R.id.number4);
        Button bt_num5 = (Button)findViewById(R.id.number5);
        Button bt_num6 = (Button)findViewById(R.id.number6);
        Button bt_num7 = (Button)findViewById(R.id.number7);
        Button bt_num8 = (Button)findViewById(R.id.number8);
        Button bt_num9 = (Button)findViewById(R.id.number9);
        Button bt_dot = (Button)findViewById(R.id.dot);
        Button bt_plus = (Button)findViewById(R.id.plus);
        Button bt_multiply = (Button)findViewById(R.id.multiply);
        Button bt_clear = (Button)findViewById(R.id.clear);
        tx_amount = (TextView)findViewById(R.id.amount);
        
        
        //tie to listener:
        bt_num0.setOnClickListener(new keyboard_listener());
        bt_num1.setOnClickListener(new keyboard_listener());
        bt_num2.setOnClickListener(new keyboard_listener());
        bt_num3.setOnClickListener(new keyboard_listener());
        bt_num4.setOnClickListener(new keyboard_listener());
        bt_num5.setOnClickListener(new keyboard_listener());
        bt_num6.setOnClickListener(new keyboard_listener());
        bt_num7.setOnClickListener(new keyboard_listener());
        bt_num8.setOnClickListener(new keyboard_listener());
        bt_num9.setOnClickListener(new keyboard_listener());
        bt_dot.setOnClickListener(new keyboard_listener());
        bt_plus.setOnClickListener(new keyboard_listener());
        bt_multiply.setOnClickListener(new keyboard_listener());
        bt_clear.setOnClickListener(new clear_listener());
        
        
    }
    
    class keyboard_listener implements OnClickListener{

		public void onClick(View v) {
			// TODO Auto-generated method stub
			Button bt = (Button)findViewById(v.getId());
			tx_amount.setText((String)tx_amount.getText()+(String)bt.getText());
		}
    	
    }
    
    class clear_listener implements OnClickListener{

		public void onClick(View v) {
			// TODO Auto-generated method stub
			tx_amount.setText("");
		}
    	
    }
    
    
    
}